<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="adminCommon::common-header">

</head>
<body class="sb-nav-fixed">
<nav th:replace="adminCommon::common-navbar"></nav>
<div id="layoutSidenav">
    <div th:replace="adminCommon::common-sidenav"></div>

    <div id="layoutSidenav_content">
        <main>
            <div class="container-fluid px-4">
                <h1 class="mt-4">添加会员</h1>

                <ol class="breadcrumb mb-4">
                    <li class="breadcrumb-item"><a th:href="@{/toAdminMain}">主页</a></li>
                    <li class="breadcrumb-item"><a th:href="@{/member/selMember}">会员管理</a></li>
                    <li class="breadcrumb-item active">添加会员</li>
                </ol>

                <div class="card mb-4">
                    <form th:action="@{/member/addMember}" method="post" name="addForm"
                          onsubmit="return beforeSubmit(this)">
                        <table class="table table-hover">
                            <tr>
                                <td text-align="center">会员账号/卡号：</td>
                                <td><input type="text" class="form-control" placeholder="卡号由系统自动生成" name="memberAccount"
                                           disabled="disabled">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">姓名：</td>
                                <td><input type="text" class="form-control" placeholder="姓名" name="memberName">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">密码：</td>
                                <td><input type="text" class="form-control" placeholder="初始密码123456"
                                           name="memberPassword" disabled="disabled">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">性别：</td>
                                <td><input type="text" class="form-control" placeholder="性别" name="memberGender">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">年龄：</td>
                                <td><input type="text" class="form-control" placeholder="年龄" name="memberAge">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">联系方式：</td>
                                <td><input type="text" class="form-control" placeholder="11位手机号" name="memberPhone">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">身高：</td>
                                <td><input type="text" class="form-control" placeholder="cm" name="memberHeight">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">体重：</td>
                                <td><input type="text" class="form-control" placeholder="kg" name="memberWeight">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">购买课时：</td>
                                <td><input type="text" class="form-control" placeholder="购买课时" name="cardClass">
                                </td>
                            </tr>
                        </table>
                        <div style="text-align:center;margin-top:20px;margin-bottom:20px">
                            <input type="submit" class="btn btn-outline-success" value="添加">
                        </div>
                    </form>
                </div>
            </div>
        </main>
        <footer th:replace="adminCommon::common-footer"></footer>
    </div>
</div>

<div th:include="adminCommon::common-scripts"></div>
<script type="text/javascript">
    function beforeSubmit(addForm) {
        let phone = /^[1][3,4,5,7,8,9][0-9]{9}$/;//设置手机号正则表达式
        if (addForm.memberName.value == "") {
            alert("请输入姓名！")
            return false;
        }
        if (addForm.memberGender.value == "") {
            alert("请输入性别！")
            return false;
        }
        if (addForm.memberAge.value == "") {
            alert("请输入年龄！")
            return false;
        }
        if (!phone.test(addForm.memberPhone.value)) {
            alert("手机号码错误！");
            return false;
        }
        if (addForm.memberHeight.value == "") {
            alert("请输入身高！")
            return false;
        }
        if (addForm.memberWeight.value == "") {
            alert("请输入体重！")
            return false;
        }
        if (addForm.cardClass.value == "") {
            alert("请输入购买课时！")
            return false;
        }
        return true;
    }
</script>
</body>
</html>
